package com.cst.security;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class Application {

	public static void main(String[] args){
		SpringApplication.run(Application.class, args);
	}

	/**
	 * 密码加密,如果是自定义加密算法需要继承PasswordEncoder，复写encode  matches  两个方法
	 * encode 用于创建用户时获得加密后的密文
	 * matches 用户登录时验证用户输入的明文是否与之匹配
	 *
	 * BCryptPasswordEncoder 加解密是自定义盐，所以哪怕同样的明文生成的密文也不一样
	 */
	@Bean
	public PasswordEncoder passwordEncoder(){
		return new BCryptPasswordEncoder();
	}


}
